package com.heng.commons.a1_过滤器;

import jakarta.servlet.*;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.io.IOException;

public class MyFilter implements Filter {

    /**
     1. 拦截器的初始化方法，执行的比较早。
     */
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("拦截器-init");
    }

    @Override
    public void destroy() {
        System.out.println("拦截器-destroy");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("过滤器");
        filterChain.doFilter(servletRequest, servletResponse);

        System.out.println("...");
    }



}
